#ifndef OBJECT_H
#define OBJECT_H

#include <QGLWidget>
#include <QDebug>
#include "camera.h"
#include <QImage>
#include <QLabel>


#define MAX_VALUE 8
#define MIN_VALUE -8

using namespace camera;


/*
    This class is designed to provide a single view of an OpenGL
    virtual enviornment
*/

class MyGLObject : public QGLWidget
{
    Q_OBJECT
public:
    MyGLObject( bool isleft, Camera * camera, QWidget *parent = 0 );
    ~MyGLObject();
    static float Change( float f1, float f2, float step );
public:
    typedef struct Mysphere
    {
        GLUquadric* qobj;
        XYZ p;
    } Mysphere;
    void keyPressEvent( QKeyEvent * );
signals:
    void cameraChanged();
    void closed();
public slots:
    void viewpointChange( int x, int y, int w );
protected:
    void initializeGL();
    void resizeGL( int w, int h );
    void paintGL();
    void drawSpheres();
    void drawMainSphere();
    void drawSquare( double x, double y, double z );
    void drawTexturedSquare( double x, double y, double z );
    void drawTexturedSquares( );
    void loadGLTexture( QString, int );
    void loadGLTextures( );
    void closeEvent ( QCloseEvent * )
    {
        emit closed();
    }

private:
    GLfloat _step;
    XYZ _obj_coord;
    bool _isleft;
    Camera * _camera;
    Mysphere* _spheres [200];
    Mysphere* _main_sphere;
    const static int WIDTH = 1024, HEIGHT = 767;
    GLfloat _y_offset;
    GLuint  texture[9];
};


#endif // OBJECT_H
